<html>
<head><meta charset="utf-8"><title>Functions in Chalk · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html">Functions in Chalk</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="231500112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231500112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231500112">(Mar 23 2021 at 16:27)</a>:</h4>
<p>So, I'm trying to work on <a href="https://github.com/rust-lang/rust/issues/688">#688</a>, particularly I'm trying to change chalk-integration's closure model to match that of rustc/rust-analyzer (where we store the closure parameters, closure kind, closure sig, and upvars all in the substitution) and honestly just opening a can of worms</p>



<a name="231500151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231500151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231500151">(Mar 23 2021 at 16:27)</a>:</h4>
<p>Maybe we can discuss this during the meeting today</p>



<a name="231500189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231500189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231500189">(Mar 23 2021 at 16:27)</a>:</h4>
<p>But, let me just go through a few things:</p>



<a name="231500504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231500504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231500504">(Mar 23 2021 at 16:29)</a>:</h4>
<p>1) <em>Why</em> the heck do we store the closure kind, sig, and upvars in the <code>Substitution</code>, instead of just alongside the <code>Id</code>. Like <code>Closure(Id, Kind, Sig, Upvars, Subst)</code></p>



<a name="231500556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231500556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231500556">(Mar 23 2021 at 16:29)</a>:</h4>
<p>I'm guessing it's because we have to infer the kind/sig/upvars</p>



<a name="231500827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231500827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231500827">(Mar 23 2021 at 16:31)</a>:</h4>
<p>2) I think the fact that Chalk's <code>Function</code> variant is <code>FnPointer</code> whereas rustc's  <code>FnPtr</code> is <code>PolyFnSig</code> is biting us here</p>



<a name="231501169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231501169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231501169">(Mar 23 2021 at 16:33)</a>:</h4>
<p>But, maybe not</p>



<a name="231516296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231516296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231516296">(Mar 23 2021 at 18:06)</a>:</h4>
<p>Re. 2: yes, it is. Since we need to represent closures with bound types too, not just bound lifetimes</p>



<a name="231516461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231516461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231516461">(Mar 23 2021 at 18:07)</a>:</h4>
<p>I.e. <code>closure foo&lt;T, U, V&gt;(&amp;self, a: &amp;'static (T, &amp;'static U), b: &amp;'static (V, U)) -&gt; Ordering {}</code> we need something like <code>for&lt;T, U, V&gt; fn(...) -&gt; Ordering</code> as a "function signature"</p>



<a name="231516740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231516740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231516740">(Mar 23 2021 at 18:08)</a>:</h4>
<p>Going back to the rust-analyzer repro:</p>
<div class="codehilite"><pre><span></span><code>fn query_and_sort_catalog(addons: &amp;[()]) {
    let mut catalog_rows_and_score = addons
        .iter()
        .filter_map(|a| Some((a, 0)))
        .filter(|(a, _)| true)
        .map(|(a, score)| (a, 0))
        .collect::&lt;Vec&lt;_&gt;&gt;();

    catalog_rows_and_score.sort_by(|(addon_a, score_a), (addon_b, score_b)| score_a.cmp(&amp;score_b));
}
</code></pre></div>
<p>We're trying to model that last closure</p>



<a name="231516936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231516936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231516936">(Mar 23 2021 at 18:10)</a>:</h4>
<p>I feel like I'm a little confused</p>



<a name="231517413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231517413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231517413">(Mar 23 2021 at 18:13)</a>:</h4>
<p>I guess that's not right</p>



<a name="231517507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231517507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231517507">(Mar 23 2021 at 18:13)</a>:</h4>
<p>The fn sig rust-analyzer was passing is:</p>
<div class="codehilite"><pre><span></span><code>for&lt;0&gt; [
    ?0 := (&amp;&#39;static 2&lt;[?0 := ^1.0, ?1 := (&amp;&#39;static ^1.1)]&gt;),
    ?1 := (&amp;&#39;static 2&lt;[?0 := ^1.2, ?1 := ^1.1]&gt;),
    ?2 := Ordering&lt;[]&gt;]
]
</code></pre></div>



<a name="231517764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231517764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231517764">(Mar 23 2021 at 18:15)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232957">Jack Huey</span> <a href="#narrow/stream/144729-wg-traits/topic/Functions.20in.20Chalk/near/231500827">said</a>:</p>
<blockquote>
<p>2) I think the fact that Chalk's <code>Function</code> variant is <code>FnPointer</code> whereas rustc's  <code>FnPtr</code> is <code>PolyFnSig</code> is biting us here</p>
</blockquote>
<p>With the latter being <code>type PolyFnSig&lt;'tcx&gt; = Binder&lt;FnSig&lt;'tcx&gt;&gt;</code>, is the difference here just that chalk is not doing <code>Binders&lt;FnSubst&lt;I&gt;&gt;</code>?</p>



<a name="231517867"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231517867" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231517867">(Mar 23 2021 at 18:16)</a>:</h4>
<p>Well, so in Chalk, <code>FnPointer</code> looks like <code>{ num_binders: u32, sig: FnSig, subst: FnSubst }</code></p>



<a name="231517924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231517924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231517924">(Mar 23 2021 at 18:16)</a>:</h4>
<p>So the <code>Binder</code> in rustc is represented in <code>num_binders</code></p>



<a name="231517977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231517977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231517977">(Mar 23 2021 at 18:17)</a>:</h4>
<p>It's weird. Because when we see <code>for&lt;'a&gt; fn(...) -&gt; Ordering</code> in Rust, you can't really have "bound vars" in the arguments</p>



<a name="231517997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231517997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231517997">(Mar 23 2021 at 18:17)</a>:</h4>
<p>Huh, but <code>FnPointer.into_binders(..)</code>fills those with all lifetimes. And you just said it can also be types?</p>



<a name="231518019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231518019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231518019">(Mar 23 2021 at 18:17)</a>:</h4>
<p>But maybe that's wrong</p>



<a name="231518086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231518086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231518086">(Mar 23 2021 at 18:18)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125131">detrumi</span> <a href="#narrow/stream/144729-wg-traits/topic/Functions.20in.20Chalk/near/231517997">said</a>:</p>
<blockquote>
<p>Huh, but <code>FnPointer.into_binders(..)</code>fills those with all lifetimes. And you just said it can also be types?</p>
</blockquote>
<p>Well, this is what I'm confused about</p>



<a name="231518156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231518156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231518156">(Mar 23 2021 at 18:18)</a>:</h4>
<p>Is essentially how to represent that closure</p>



<a name="231518242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231518242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231518242">(Mar 23 2021 at 18:19)</a>:</h4>
<p>(<a href="https://github.com/detrumi/chalk/blob/2b4b3376f5d3ce1dea604e5e78c860b9eb880225/chalk-ir/src/lib.rs#L1120-L1120">the function I was talking about</a>)</p>



<a name="231518402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231518402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231518402">(Mar 23 2021 at 18:20)</a>:</h4>
<p>So, a <code>FnPtr</code> or <code>FnPointer</code> essentially you can think about as literally a pointer to a function</p>



<a name="231518455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231518455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231518455">(Mar 23 2021 at 18:20)</a>:</h4>
<p>And, more so, a <em>monomorphized</em> function</p>



<a name="231518539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231518539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231518539">(Mar 23 2021 at 18:21)</a>:</h4>
<p>So, it doesn't <em>quite</em> make sense to write <code>for&lt;T&gt; fn(T)</code></p>



<a name="231518775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231518775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231518775">(Mar 23 2021 at 18:23)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232957">Jack Huey</span> <a href="#narrow/stream/144729-wg-traits/topic/Functions.20in.20Chalk/near/231517507">said</a>:</p>
<blockquote>
<p>The fn sig rust-analyzer was passing is:</p>
<p><div class="codehilite"><pre><span></span><code>for&lt;0&gt; [
    ?0 := (&amp;&#39;static 2&lt;[?0 := ^1.0, ?1 := (&amp;&#39;static ^1.1)]&gt;),
    ?1 := (&amp;&#39;static 2&lt;[?0 := ^1.2, ?1 := ^1.1]&gt;),
    ?2 := Ordering&lt;[]&gt;]
]
</code></pre></div><br>
</p>
</blockquote>
<p>I guess, going back to this, I need to figure out how to represent "some unknown closure" in the chalk tests</p>



<a name="231518833"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231518833" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231518833">(Mar 23 2021 at 18:23)</a>:</h4>
<p>That would at the very least help with reproducing these bugs</p>



<a name="231518939"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231518939" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231518939">(Mar 23 2021 at 18:24)</a>:</h4>
<p>The existing infrastructure is all based around the state where we <em>know</em> the signature of a function</p>



<a name="231519275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231519275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231519275">(Mar 23 2021 at 18:26)</a>:</h4>
<p>It's also kind of weird to try to fit the current testing into the rustc/rust-analyzer style</p>



<a name="231519322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231519322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231519322">(Mar 23 2021 at 18:27)</a>:</h4>
<p>Because the current form <em>does allow</em> bound types</p>



<a name="231519351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231519351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231519351">(Mar 23 2021 at 18:27)</a>:</h4>
<p>closures can't have type parameters, in my understanding</p>



<a name="231519365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231519365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231519365">(Mar 23 2021 at 18:27)</a>:</h4>
<p>(maybe)</p>



<a name="231519401"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231519401" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231519401">(Mar 23 2021 at 18:27)</a>:</h4>
<p>the unknown types in the closure are represented by type variables</p>



<a name="231519524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231519524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231519524">(Mar 23 2021 at 18:28)</a>:</h4>
<p>But, should those be bound vars or placeholders?</p>



<a name="231519619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231519619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231519619">(Mar 23 2021 at 18:28)</a>:</h4>
<p>during inference, they're actual type variables. when passing them to chalk they get canonicalized and turned into bound vars</p>



<a name="231519750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231519750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231519750">(Mar 23 2021 at 18:29)</a>:</h4>
<p>the other difference, is in the chalk-integration tests, the closure parameters can be named in the upvars</p>



<a name="231520113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231520113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231520113">(Mar 23 2021 at 18:31)</a>:</h4>
<p>Okay, yeah, talking through this, I'm convinced that I need need to change the way closures are written/parsed</p>



<a name="231520170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231520170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231520170">(Mar 23 2021 at 18:32)</a>:</h4>
<p>Specifically, we need <em>two</em> levels of parameters</p>



<a name="231520197"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231520197" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231520197">(Mar 23 2021 at 18:32)</a>:</h4>
<p>well</p>



<a name="231520267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231520267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231520267">(Mar 23 2021 at 18:32)</a>:</h4>
<p>actually, I guess I could get away with just not doing late bound vars</p>



<a name="231521208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231521208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231521208">(Mar 23 2021 at 18:38)</a>:</h4>
<p>I have a feeling things are going to blow up because I'm going to have escaping bound vars</p>



<a name="231838799"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231838799" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231838799">(Mar 25 2021 at 17:04)</a>:</h4>
<p>Okay, who's around for me to bounce thoughts off of? <span class="user-mention" data-user-id="125131">@detrumi</span>?</p>



<a name="231838845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231838845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231838845">(Mar 25 2021 at 17:04)</a>:</h4>
<p>So, closures and such aside</p>



<a name="231838875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231838875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231838875">(Mar 25 2021 at 17:04)</a>:</h4>
<p>let's look at</p>
<div class="codehilite"><pre><span></span><code>Implemented({closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [
    ?0 := (&amp;&#39;static 2&lt;[?0 := ^1.0, ?1 := (&amp;&#39;static ^1.1)]&gt;),
    ?1 := (&amp;&#39;static 2&lt;[?0 := ^1.2, ?1 := ^1.1]&gt;),
    ?2 := Ordering&lt;[]&gt;]
]&gt; : FnMut&lt;2&lt;[
    ?0 := (&amp;&#39;static 2&lt;[?0 := ^0.3, ?1 := ^0.4]&gt;),
    ?1 := (&amp;&#39;static 2&lt;[?0 := ^0.3, ?1 := ^0.4]&gt;)
]&gt;&gt;)
</code></pre></div>



<a name="231838955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231838955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231838955">(Mar 25 2021 at 17:04)</a>:</h4>
<p>oh hey</p>



<a name="231839025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231839025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231839025">(Mar 25 2021 at 17:05)</a>:</h4>
<p>Essentially, this creates a goal: </p>
<div class="codehilite"><pre><span></span><code>for&lt;0&gt; [
    ?0 := (&amp;&#39;static 2&lt;[?0 := ^1.0, ?1 := (&amp;&#39;static ^1.1)]&gt;),
    ?1 := (&amp;&#39;static 2&lt;[?0 := ^1.2, ?1 := ^1.1]&gt;),
    ?2 := Ordering&lt;[]&gt;]
]: FnMut&lt;2&lt;[
    ?0 := (&amp;&#39;static 2&lt;[?0 := ^0.3, ?1 := ^0.4]&gt;),
    ?1 := (&amp;&#39;static 2&lt;[?0 := ^0.3, ?1 := ^0.4]&gt;)
]&gt;&gt;
</code></pre></div>



<a name="231839074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231839074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231839074">(Mar 25 2021 at 17:05)</a>:</h4>
<p>And look at that</p>



<a name="231839236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231839236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231839236">(Mar 25 2021 at 17:06)</a>:</h4>
<p>Eventually, we're going to end up with something like:<br>
<code>(&amp;'static 2&lt;[?0 := ^1.0, ?1 := (&amp;'static ^1.1)]&gt;) == (&amp;'static 2&lt;[?0 := ^0.3, ?1 := ^0.4]&gt;)</code> and <code>(&amp;'static 2&lt;[?0 := ^1.2, ?1 := ^1.1]&gt;) == (&amp;'static 2&lt;[?0 := ^0.3, ?1 := ^0.4]&gt;)</code></p>



<a name="231839309"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231839309" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231839309">(Mar 25 2021 at 17:06)</a>:</h4>
<p>Do the two <code>?0</code>'s in <code>?0 := (&amp;'static 2&lt;[?0</code> refer to the same thing here?</p>



<a name="231839355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231839355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231839355">(Mar 25 2021 at 17:06)</a>:</h4>
<p>no :/</p>



<a name="231839420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231839420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231839420">(Mar 25 2021 at 17:07)</a>:</h4>
<p>debug here is a bit confusing</p>



<a name="231839437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231839437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231839437">(Mar 25 2021 at 17:07)</a>:</h4>
<p>I would prefer it just as a list</p>



<a name="231839490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231839490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231839490">(Mar 25 2021 at 17:07)</a>:</h4>
<p>Yeah, having trouble parsing this</p>



<a name="231839601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231839601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231839601">(Mar 25 2021 at 17:08)</a>:</h4>
<p>Something like </p>
<div class="codehilite"><pre><span></span><code>for&lt;0&gt; [
    (&amp;&#39;static 2&lt;[^1.0, (&amp;&#39;static ^1.1)]&gt;),
    (&amp;&#39;static 2&lt;[^1.2, ^1.1]&gt;),
    Ordering&lt;[]&gt;]
]: FnMut&lt;2&lt;[
    (&amp;&#39;static 2&lt;[^0.3, ^0.4]&gt;),
    (&amp;&#39;static 2&lt;[^0.3, ^0.4]&gt;)
]&gt;&gt;
</code></pre></div>



<a name="231839667"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231839667" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231839667">(Mar 25 2021 at 17:08)</a>:</h4>
<p>Better?</p>



<a name="231839697"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231839697" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231839697">(Mar 25 2021 at 17:08)</a>:</h4>
<p>Sort of importantly</p>



<a name="231839735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231839735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231839735">(Mar 25 2021 at 17:08)</a>:</h4>
<p>Both <code>(&amp;'static ^1.1)</code> and <code>^1.1</code> get unifed with <code>^0.4</code></p>



<a name="231839798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231839798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231839798">(Mar 25 2021 at 17:09)</a>:</h4>
<p>And yeah, that's gonna cause a cycle if we don't detect that</p>



<a name="231839982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231839982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231839982">(Mar 25 2021 at 17:10)</a>:</h4>
<p>I've also been able to refactor things around to get this goal locally: <code>Normalize(&lt;{closure:ClosureId(#4)}&lt;^0.0, ^0.1, ^0.2, Int(I8), "rust" for&lt;0&gt; [?0 := (&amp;'static 2&lt;^1.0, (&amp;'static ^1.1)&gt;), ?1 := (&amp;'static 2&lt;^1.2, ^1.1&gt;), ?2 := Ordering], 0&gt; as FnOnce&lt;2&lt;(&amp;'static 2&lt;^0.3, ^0.4&gt;), (&amp;'static 2&lt;^0.3, ^0.4&gt;)&gt;&gt;&gt;::Output -&gt; Ordering)</code></p>



<a name="231840003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231840003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231840003">(Mar 25 2021 at 17:10)</a>:</h4>
<p>which looks very similar</p>



<a name="231840032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231840032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231840032">(Mar 25 2021 at 17:10)</a>:</h4>
<p>But I'm not getting a cycle, just "No solution"</p>



<a name="231840080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231840080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231840080">(Mar 25 2021 at 17:11)</a>:</h4>
<p>So not sure if maybe the refactorings I've made locally <em>fixed</em> it, or if still no reproing</p>



<a name="231840199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231840199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231840199">(Mar 25 2021 at 17:11)</a>:</h4>
<p>Actually though, we <em>do</em> catch this locally:</p>
<div class="codehilite"><pre><span></span><code>0ms DEBUG trying fold_with on (&amp;&#39;static ?8)
0ms DEBUG OccursCheck aborting because ?8 unioned with ?6
0ms DEBUG failed to fold (&amp;&#39;static ?8)
</code></pre></div>



<a name="231840348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231840348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231840348">(Mar 25 2021 at 17:12)</a>:</h4>
<p>So OccursCheck is what's preventing the cycle normally, right?</p>



<a name="231840373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231840373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231840373">(Mar 25 2021 at 17:12)</a>:</h4>
<p>Yeah</p>



<a name="231840510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231840510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231840510">(Mar 25 2021 at 17:13)</a>:</h4>
<p>So the question then becomes, what's special about the earlier goal that's not being caught by the check</p>



<a name="231840629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231840629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231840629">(Mar 25 2021 at 17:14)</a>:</h4>
<p>Right. It's a bit difficult because in the debug log you sent, there's no <code>chalk_solve</code> debugging, only <code>chalk_recursive</code></p>



<a name="231840865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231840865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231840865">(Mar 25 2021 at 17:15)</a>:</h4>
<p>Hm. Let me spin up the repro again</p>



<a name="231840977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231840977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231840977">(Mar 25 2021 at 17:16)</a>:</h4>
<p>Though it's weird how there's no <code>chalk_solve</code> logging then, since that's just controlled by <code>CHALK_DEBUG=3</code> here</p>



<a name="231841356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231841356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231841356">(Mar 25 2021 at 17:19)</a>:</h4>
<p>I guess it mentions OccursCheck once with <code>CHALK_DEBUG=4</code>:</p>
<div class="codehilite"><pre><span></span><code>│ │ │ │ │ │ │ ├─0ms DEBUG zip_tys Invariant, (&amp;&#39;static 2&lt;[?0 := ?3, ?1 := ?4]&gt;), (&amp;&#39;static 2&lt;[?0 := ?7, ?1 := ?6]&gt;)
│ │ │ │ │ │ │ ├─┐relate_ty_ty variance=Invariant, a=(&amp;&#39;static 2&lt;[?0 := ?3, ?1 := ?4]&gt;), b=(&amp;&#39;static 2&lt;[?0 := ?7, ?1 := ?6]&gt;)
│ │ │ │ │ │ │ │ ├─┐relate_lifetime_lifetime variance=Invariant, a=&#39;static, b=&#39;static
│ │ │ │ │ │ │ │ ├─┘
│ │ │ │ │ │ │ │ ├─0ms DEBUG zip_tys Invariant, 2&lt;[?0 := ?3, ?1 := ?4]&gt;, 2&lt;[?0 := ?7, ?1 := ?6]&gt;
│ │ │ │ │ │ │ │ ├─┐relate_ty_ty variance=Invariant, a=2&lt;[?0 := ?3, ?1 := ?4]&gt;, b=2&lt;[?0 := ?7, ?1 := ?6]&gt;
│ │ │ │ │ │ │ │ │ ├─0ms DEBUG zip_tys Invariant, ?3, ?7
│ │ │ │ │ │ │ │ │ ├─┐relate_ty_ty variance=Invariant, a=?3, b=?7
│ │ │ │ │ │ │ │ │ │ ├─┐unify_var_var a=?3, b=?7
│ │ │ │ │ │ │ │ │ │ ├─┘
│ │ │ │ │ │ │ │ │ ├─┘
│ │ │ │ │ │ │ │ │ ├─0ms DEBUG zip_tys Invariant, ?4, ?6
│ │ │ │ │ │ │ │ │ ├─┐relate_ty_ty variance=Invariant, a=(&amp;&#39;static ?10), b=?6
│ │ │ │ │ │ │ │ │ │ ├─┐relate_var_ty variance=Invariant, var=?6, var_kind=General, ty=(&amp;&#39;static ?10)
│ │ │ │ │ │ │ │ │ │ │ ├─0ms DEBUG relate_var_ty: universe index of var: U0
│ │ │ │ │ │ │ │ │ │ │ ├─0ms DEBUG trying fold_with on (&amp;&#39;static ?10)
│ │ │ │ │ │ │ │ │ │ │ ├─0ms DEBUG OccursCheck aborting because ?10 unioned with ?6
│ │ │ │ │ │ │ │ │ │ │ ├─0ms DEBUG failed to fold (&amp;&#39;static ?10)
│ │ │ │ │ │ │ │ │ │ ├─┘
</code></pre></div>



<a name="231841545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231841545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231841545">(Mar 25 2021 at 17:20)</a>:</h4>
<p>I would just do <code>CHALK_DEBUG=debug</code></p>



<a name="231841650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231841650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231841650">(Mar 25 2021 at 17:21)</a>:</h4>
<p>That gets me the same output style</p>



<a name="231841739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231841739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231841739">(Mar 25 2021 at 17:21)</a>:</h4>
<p>as <code>=4</code>?</p>



<a name="231841755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231841755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231841755">(Mar 25 2021 at 17:21)</a>:</h4>
<p>yeah</p>



<a name="231841781"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231841781" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231841781">(Mar 25 2021 at 17:21)</a>:</h4>
<p>Can you post the log with chalk_solve output?</p>



<a name="231842048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231842048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231842048">(Mar 25 2021 at 17:23)</a>:</h4>
<p>GitHub doesn't like 200K lines in a gist, one moment...</p>



<a name="231842246"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231842246" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231842246">(Mar 25 2021 at 17:24)</a>:</h4>
<p>I really only need the first few cycles</p>



<a name="231842275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231842275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231842275">(Mar 25 2021 at 17:24)</a>:</h4>
<p>I think 3-4 is generally more than enough</p>



<a name="231842339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231842339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231842339">(Mar 25 2021 at 17:25)</a>:</h4>
<p>From what I could tell, it seems like it's growing in two different places, alternating</p>



<a name="231842387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231842387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231842387">(Mar 25 2021 at 17:25)</a>:</h4>
<p>That OccursCheck snippet I sent above is on line 100443, so not entirely sure about that</p>



<a name="231842420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231842420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231842420">(Mar 25 2021 at 17:25)</a>:</h4>
<p>woah</p>



<a name="231842457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231842457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231842457">(Mar 25 2021 at 17:25)</a>:</h4>
<p>I mean, I would expect the OccursCheck to happen much sooner</p>



<a name="231842558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231842558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231842558">(Mar 25 2021 at 17:26)</a>:</h4>
<p>Locally it happens line 225</p>



<a name="231842696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231842696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231842696">(Mar 25 2021 at 17:27)</a>:</h4>
<p><a href="https://gist.github.com/detrumi/5d91e8fc419f9107bfa86ec9514d1e8f">https://gist.github.com/detrumi/5d91e8fc419f9107bfa86ec9514d1e8f</a></p>



<a name="231842794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231842794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231842794">(Mar 25 2021 at 17:27)</a>:</h4>
<p>That's 94K lines until the OccursCheck mention</p>



<a name="231842877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231842877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231842877">(Mar 25 2021 at 17:28)</a>:</h4>
<p>(with invocation <code>CHALK_DEBUG=debug cargo run --release -p rust-analyzer -- analysis-stats ../tryout</code>)</p>



<a name="231843063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231843063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231843063">(Mar 25 2021 at 17:29)</a>:</h4>
<p>What is the <code>../tryout</code></p>



<a name="231843209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231843209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231843209">(Mar 25 2021 at 17:30)</a>:</h4>
<p><code>analysis-stats</code> takes as argument a path to a directory with rust files, <code>tryout</code> holds a cargo project with the repro</p>



<a name="231843234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231843234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231843234">(Mar 25 2021 at 17:30)</a>:</h4>
<p>oh okay</p>



<a name="231843390"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231843390" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231843390">(Mar 25 2021 at 17:31)</a>:</h4>
<p>It's an useful rust-analyzer tool to analyze a project from the command line instead of from the editor</p>



<a name="231843511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231843511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231843511">(Mar 25 2021 at 17:32)</a>:</h4>
<p>I also wonder if the repro could be minimized a bit more</p>



<a name="231843601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231843601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231843601">(Mar 25 2021 at 17:32)</a>:</h4>
<div class="codehilite"><pre><span></span><code>    let mut catalog_rows_and_score = addons
        .iter()
        .map(|a| (a, 0))
        .collect::&lt;Vec&lt;_&gt;&gt;();
</code></pre></div>



<a name="231843747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231843747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231843747">(Mar 25 2021 at 17:33)</a>:</h4>
<p>Or if rust-analyzer doesn't give Chalk such an obscure goal</p>



<a name="231844014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231844014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231844014">(Mar 25 2021 at 17:35)</a>:</h4>
<p>That doesn't reproduce it</p>



<a name="231844163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231844163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231844163">(Mar 25 2021 at 17:36)</a>:</h4>
<p>interesting</p>



<a name="231844362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231844362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231844362">(Mar 25 2021 at 17:37)</a>:</h4>
<p>I was wondering why I couldn't find the relevant goal then I realized github hid everything after 9k lines</p>



<a name="231844533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231844533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231844533">(Mar 25 2021 at 17:38)</a>:</h4>
<p>Interesting how even that <code>filter(|(a, _)| true)</code> makes a difference</p>



<a name="231844671"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231844671" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231844671">(Mar 25 2021 at 17:39)</a>:</h4>
<p>Though replacing that part with <code>map(|x| x)</code> still reproduces, so apparently it's the indirection that's important</p>



<a name="231844847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231844847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231844847">(Mar 25 2021 at 17:40)</a>:</h4>
<p>So the relevant goal doesn't actually happen until near the end of the file</p>



<a name="231844915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231844915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231844915">(Mar 25 2021 at 17:41)</a>:</h4>
<p>But, this is different anyways: <code>Implemented({closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := ^1.0, ?1 := ^1.1, ?2 := ^1.2]]&gt;: FnMut&lt;2&lt;[?0 := (&amp;'static ^0.3), ?1 := (&amp;'static ^0.3)]&gt;&gt;)</code></p>



<a name="231845239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231845239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231845239">(Mar 25 2021 at 17:43)</a>:</h4>
<p>So I don't know if you captured the goal</p>



<a name="231845324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231845324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231845324">(Mar 25 2021 at 17:43)</a>:</h4>
<p>err nvm</p>



<a name="231845481"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231845481" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231845481">(Mar 25 2021 at 17:44)</a>:</h4>
<p>Given that it only mentions <code>OccursCheck aborting</code> once, maybe it only starts nesting goals after that</p>



<a name="231845528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231845528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231845528">(Mar 25 2021 at 17:45)</a>:</h4>
<p>in which case I didn't put the relevant part of the log in the gist</p>



<a name="231845721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231845721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231845721">(Mar 25 2021 at 17:46)</a>:</h4>
<p>Okay I see <code>AliasEq(&lt;{closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;'static 2&lt;[?0 := ^1.0, ?1 := ^1.1]&gt;), ?1 := (&amp;'static 2&lt;[?0 := ^1.2, ?1 := ^1.3]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt; as FnOnce&lt;2&lt;[?0 := (&amp;'static 2&lt;[?0 := ^0.4, ?1 := ^0.5]&gt;), ?1 := (&amp;'static 2&lt;[?0 := ^0.4, ?1 := ^0.5]&gt;)]&gt;&gt;&gt;::Output = Ordering&lt;[]&gt;)</code></p>



<a name="231846202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231846202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231846202">(Mar 25 2021 at 17:49)</a>:</h4>
<p>Okay found <code>Normalize(&lt;{closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;'static 2&lt;[?0 := ^1.0, ?1 := ^1.1]&gt;), ?1 := (&amp;'static 2&lt;[?0 := ^1.2, ?1 := ^1.3]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt; as FnOnce&lt;2&lt;[?0 := (&amp;'static 2&lt;[?0 := ^0.4, ?1 := ^0.5]&gt;), ?1 := (&amp;'static 2&lt;[?0 := ^0.4, ?1 := ^0.5]&gt;)]&gt;&gt;&gt;::Output -&gt; Ordering&lt;[]&gt;)</code></p>



<a name="231846686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231846686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231846686">(Mar 25 2021 at 17:52)</a>:</h4>
<p><code>pushed clause Some(for&lt;type, type, type, type&gt; Normalize(&lt;{closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;'static 2&lt;[?0 := ^1.0, ?1 := ^1.1]&gt;), ?1 := (&amp;'static 2&lt;[?0 := ^1.2, ?1 := ^1.3]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt; as FnOnce&lt;2&lt;[?0 := (&amp;'static 2&lt;[?0 := ^0.0, ?1 := ^0.1]&gt;), ?1 := (&amp;'static 2&lt;[?0 := ^0.2, ?1 := ^0.3]&gt;)]&gt;&gt;&gt;::Output -&gt; Ordering&lt;[]&gt;))</code></p>



<a name="231846719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231846719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231846719">(Mar 25 2021 at 17:52)</a>:</h4>
<p><code>pushed clause Some(for&lt;type, type, type&gt; Normalize(&lt;{closure:ClosureId(#4)}&lt;^0.0, ^0.1, ^0.2, Int(I8), "rust" for&lt;0&gt; [?0 := (&amp;'static 2&lt;^1.0, (&amp;'static ^1.1)&gt;), ?1 := (&amp;'static 2&lt;^1.2, ^1.1&gt;), ?2 := Ordering], 0&gt; as FnOnce&lt;2&lt;(&amp;'static 2&lt;^0.0, (&amp;'static ^0.1)&gt;), (&amp;'static 2&lt;^0.2, ^0.1&gt;)&gt;&gt;&gt;::Output -&gt; Ordering))</code></p>



<a name="231846747"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231846747" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231846747">(Mar 25 2021 at 17:52)</a>:</h4>
<p>key difference between what you gave and what's happening locally</p>



<a name="231847013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231847013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231847013">(Mar 25 2021 at 17:54)</a>:</h4>
<p>Welp I think I know what fixed it locally</p>



<a name="231847189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231847189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231847189">(Mar 25 2021 at 17:55)</a>:</h4>
<p>It was a solver bug then?</p>



<a name="231847264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231847264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231847264">(Mar 25 2021 at 17:55)</a>:</h4>
<p>I'm not saying it's anything yet</p>



<a name="231847275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231847275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231847275">(Mar 25 2021 at 17:55)</a>:</h4>
<p>Until I know this is why it's fixed</p>



<a name="231847366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231847366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231847366">(Mar 25 2021 at 17:56)</a>:</h4>
<p>Welp nope</p>



<a name="231847549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231847549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231847549">(Mar 25 2021 at 17:57)</a>:</h4>
<p>I mean, this is <em>probably</em> the correct point of failure</p>



<a name="231848432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231848432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231848432">(Mar 25 2021 at 18:02)</a>:</h4>
<p>And more so.<br>
Locally, I have </p>
<div class="codehilite"><pre><span></span><code>push_binders{binders=for&lt;&gt; FnDefInputsAndOutputDatum { argument_types: [(&amp;&#39;static 2&lt;^1.0, (&amp;&#39;static ^1.1)&gt;), (&amp;&#39;static 2&lt;^1.2, ^1.1&gt;)], return_type: Ordering }}
</code></pre></div>
<p>In rust-analyzer, it:</p>
<div class="codehilite"><pre><span></span><code>push_binders binders=for&lt;&gt; FnDefInputsAndOutputDatum { argument_types: [(&amp;&#39;static 2&lt;[?0 := ^1.0, ?1 := ^1.1]&gt;), (&amp;&#39;static 2&lt;[?0 := ^1.2, ?1 := ^1.3]&gt;)], return_type: Ordering&lt;[]&gt; }
</code></pre></div>



<a name="231849113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231849113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231849113">(Mar 25 2021 at 18:06)</a>:</h4>
<p>So, rust-analyzer just isn't giving Chalk the right <code>FnDefInputsAndOutputDatum</code>?</p>



<a name="231849230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231849230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231849230">(Mar 25 2021 at 18:06)</a>:</h4>
<p>So <a href="https://github.com/rust-analyzer/rust-analyzer/blob/8e7e405f6ab0c1ee10bfdd3d55a97628fe4cd6dd/crates/hir_ty/src/traits/chalk.rs#L281-L281">closure_inputs_and_output</a>?</p>



<a name="231849310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231849310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231849310">(Mar 25 2021 at 18:07)</a>:</h4>
<p>Yeah but I don't <em>see</em> anything wrong with that</p>



<a name="231849425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231849425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231849425">(Mar 25 2021 at 18:08)</a>:</h4>
<p>oh wait</p>



<a name="231849426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231849426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231849426">(Mar 25 2021 at 18:08)</a>:</h4>
<p>nvm</p>



<a name="231849501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231849501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231849501">(Mar 25 2021 at 18:08)</a>:</h4>
<p><code>value={closure:ClosureId(#4)}&lt;^0.0, ^0.1, ^0.2, Int(I8), "rust" for&lt;0&gt; [?0 := (&amp;'static 2&lt;^1.0, (&amp;'static ^1.1)&gt;), ?1 := (&amp;'static 2&lt;^1.2, ^1.1&gt;), ?2 := Ordering], 0&gt;</code> local</p>



<a name="231849540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231849540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231849540">(Mar 25 2021 at 18:08)</a>:</h4>
<p><code>value={closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;'static 2&lt;[?0 := ^1.0, ?1 := ^1.1]&gt;), ?1 := (&amp;'static 2&lt;[?0 := ^1.2, ?1 := ^1.3]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt;</code> rust-analyzer</p>



<a name="231849567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231849567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231849567">(Mar 25 2021 at 18:08)</a>:</h4>
<p>So it's further up from there</p>



<a name="231850520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231850520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231850520">(Mar 25 2021 at 18:14)</a>:</h4>
<p>So how do we get from <code>program_clauses_that_could_match goal=UCanonical { canonical: Canonical { value: InEnvironment { environment: Env([]), goal: Normalize(&lt;{closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;'static 2&lt;[?0 := ^1.0, ?1 := ^1.1]&gt;), ?1 := (&amp;'static 2&lt;[?0 := ^1.2, ?1 := ^1.3]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt; as FnOnce&lt;2&lt;[?0 := (&amp;'static 2&lt;[?0 := ^0.4, ?1 := ^0.5]&gt;), ?1 := (&amp;'static 2&lt;[?0 := ^0.4, ?1 := ^0.5]&gt;)]&gt;&gt;&gt;::Output -&gt; Ordering&lt;[]&gt;) }, binders: [U0 with kind type, U0 with kind type, U0 with kind type, U0 with kind type, U0 with kind type, U0 with kind type] }, universes: 1 }</code></p>



<a name="231850548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231850548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231850548">(Mar 25 2021 at 18:14)</a>:</h4>
<p>To <code>push_binders binders=for&lt;type, type, type, type&gt; {closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;'static 2&lt;[?0 := ^1.0, ?1 := ^1.1]&gt;), ?1 := (&amp;'static 2&lt;[?0 := ^1.2, ?1 := ^1.3]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt;</code></p>



<a name="231850619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231850619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231850619">(Mar 25 2021 at 18:15)</a>:</h4>
<p>oops</p>



<a name="231850831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231850831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231850831">(Mar 25 2021 at 18:16)</a>:</h4>
<p>okay wait</p>



<a name="231850839"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231850839" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231850839">(Mar 25 2021 at 18:16)</a>:</h4>
<p>I've confused myself</p>



<a name="231850985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231850985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231850985">(Mar 25 2021 at 18:17)</a>:</h4>
<p>These aren't the same goals</p>



<a name="231851593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231851593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231851593">(Mar 25 2021 at 18:21)</a>:</h4>
<p>Okay so it seems like the goal in <a href="https://github.com/rust-lang/rust/issues/688">#688</a> isn't necessarily the "start" of the madness</p>



<a name="231851793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231851793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231851793">(Mar 25 2021 at 18:22)</a>:</h4>
<p>There's a lot of queries before that yeah</p>



<a name="231852494"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231852494" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231852494">(Mar 25 2021 at 18:27)</a>:</h4>
<p>yeah I don't actually see this goal here</p>



<a name="231852683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231852683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231852683">(Mar 25 2021 at 18:29)</a>:</h4>
<p>OccursCheck happens under: <code>solve_from_clauses clause=for&lt;type, type, type, type, type&gt; Implemented({closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;'static 2&lt;[?0 := ^1.0, ?1 := (&amp;'static ^1.1)]&gt;), ?1 := (&amp;'static 2&lt;[?0 := ^1.2, ?1 := ^1.1]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt;: FnMut&lt;2&lt;[?0 := (&amp;'static 2&lt;[?0 := ^0.0, ?1 := (&amp;'static ^0.1)]&gt;), ?1 := (&amp;'static 2&lt;[?0 := ^0.2, ?1 := ^0.1]&gt;)]&gt;&gt;)</code></p>



<a name="231852771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231852771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231852771">(Mar 25 2021 at 18:29)</a>:</h4>
<p>I assume it's the last top-level goal, so this one:</p>
<div class="codehilite"><pre><span></span><code>[INFO hir_ty::traits] trait_solve_query(Normalize(&lt;|&amp;(?0.0, &amp;?0.1), &amp;(?0.2, ?0.1)| -&gt; Ordering as FnOnce&lt;(&amp;(?0.3, ?0.4), &amp;(?0.3, ?0.4))&gt;&gt;::Output =&gt; Ordering))
</code></pre></div>



<a name="231852810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231852810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231852810">(Mar 25 2021 at 18:29)</a>:</h4>
<p>(from the list I included <a href="https://github.com/rust-lang/chalk/issues/688#issuecomment-798983783">here</a>)</p>



<a name="231852931"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231852931" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231852931">(Mar 25 2021 at 18:30)</a>:</h4>
<p>yes</p>



<a name="231853021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231853021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231853021">(Mar 25 2021 at 18:30)</a>:</h4>
<p>can you post the ouput with chalk_solve debug</p>



<a name="231853136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231853136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231853136">(Mar 25 2021 at 18:31)</a>:</h4>
<p>huh?</p>



<a name="231853258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231853258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231853258">(Mar 25 2021 at 18:32)</a>:</h4>
<p>I already posted the full output, or did you need more of the output there after the occurs check?</p>



<a name="231853432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231853432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231853432">(Mar 25 2021 at 18:33)</a>:</h4>
<p>oh yeah, way more after the occurs check</p>



<a name="231853631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231853631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231853631">(Mar 25 2021 at 18:34)</a>:</h4>
<p>I think the last query you posted is the query <em>before</em> the one we want</p>



<a name="231853655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231853655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231853655">(Mar 25 2021 at 18:34)</a>:</h4>
<div class="codehilite"><pre><span></span><code>[INFO hir_ty::traits] trait_solve_query(Implements(|&amp;(?0.0, &amp;?0.1), &amp;(?0.2, ?0.1)| -&gt; Ordering: FnMut&lt;(&amp;(?0.3, ?0.4), &amp;(?0.3, ?0.4))&gt;))
[INFO hir_ty::traits] trait_solve_query(Normalize(&lt;|&amp;(?0.0, &amp;?0.1), &amp;(?0.2, ?0.1)| -&gt; Ordering as FnOnce&lt;(&amp;(?0.3, ?0.4), &amp;(?0.3, ?0.4))&gt;&gt;::Output =&gt; Ordering))
</code></pre></div>



<a name="231853998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231853998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231853998">(Mar 25 2021 at 18:36)</a>:</h4>
<p>Another run, but this time from the occurs check onwards: <a href="https://gist.github.com/detrumi/f279f38e4116e7779e0a3e9e0ba6ffdd">https://gist.github.com/detrumi/f279f38e4116e7779e0a3e9e0ba6ffdd</a></p>



<a name="231854095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231854095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231854095">(Mar 25 2021 at 18:37)</a>:</h4>
<p><code>goal: AliasEq(&lt;{closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;'static 2&lt;[?0 := ^1.0, ?1 := (&amp;'static ^1.1)]&gt;), ?1 := (&amp;'static 2&lt;[?0 := ^1.2, ?1 := ^1.1]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt; as FnOnce&lt;2&lt;[?0 := (&amp;'static 2&lt;[?0 := ^0.3, ?1 := ^0.4]&gt;), ?1 := (&amp;'static 2&lt;[?0 := ^0.3, ?1 := ^0.4]&gt;)]&gt;&gt;&gt;::Output = Ordering&lt;[]&gt;)</code></p>



<a name="231854100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231854100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231854100">(Mar 25 2021 at 18:37)</a>:</h4>
<p>there we go</p>



<a name="231855949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231855949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231855949">(Mar 25 2021 at 18:49)</a>:</h4>
<p>Okay, so local: </p>
<div class="codehilite"><pre><span></span><code>Normalize(&lt;{closure:ClosureId(#4)}&lt;^0.0, &#39;^0.1, ^0.2, ^0.3, ^0.4, Int(I8), &quot;rust&quot; for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;^1.0, (&amp;&#39;^1.1 ^1.2)&gt;), ?1 := (&amp;&#39;static 2&lt;^1.3, ^1.4&gt;), ?2 := Ordering], 0&gt; as FnOnce&lt;2&lt;(&amp;&#39;static 2&lt;^0.5, ^0.6&gt;), (&amp;&#39;static 2&lt;^0.5, ^0.6&gt;)&gt;&gt;&gt;::Output -&gt; Ordering)
</code></pre></div>



<a name="231856055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231856055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231856055">(Mar 25 2021 at 18:50)</a>:</h4>
<p>rust-analyzer</p>
<div class="codehilite"><pre><span></span><code>Normalize(&lt;{closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;[?0 := ^1.0, ?1 := (&amp;&#39;^1.1 ^1.2)]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ^1.3, ?1 := ^1.4]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt; as FnOnce&lt;2&lt;[?0 := (&amp;&#39;static 2&lt;[?0 := ^0.5, ?1 := ^0.6]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ^0.5, ?1 := ^0.6]&gt;)]&gt;&gt;&gt;::Output -&gt; Ordering&lt;[]&gt;)
</code></pre></div>



<a name="231856215"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231856215" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231856215">(Mar 25 2021 at 18:51)</a>:</h4>
<p>Those look identical except of the extra fn substs locally</p>



<a name="231856385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231856385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231856385">(Mar 25 2021 at 18:52)</a>:</h4>
<p>Yeah, they look the same</p>



<a name="231860185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231860185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231860185">(Mar 25 2021 at 19:16)</a>:</h4>
<p>The inputs and output and we get back is different:<br>
rust-analyzer</p>
<div class="codehilite"><pre><span></span><code>for&lt;&gt; FnDefInputsAndOutputDatum { argument_types: [(&amp;&#39;static 2&lt;[?0 := ^1.0, ?1 := (&amp;&#39;static ^1.2)]&gt;), (&amp;&#39;static 2&lt;[?0 := ^1.3, ?1 := ^1.4]&gt;)], return_type: Ordering&lt;[]&gt; }
</code></pre></div>
<p>local</p>
<div class="codehilite"><pre><span></span><code>for&lt;&gt; FnDefInputsAndOutputDatum { argument_types: [(&amp;&#39;static 2&lt;^1.0, (&amp;&#39;^1.1 ^1.2)&gt;), (&amp;&#39;static 2&lt;^1.3, ^1.4&gt;)], return_type: Ordering }
</code></pre></div>



<a name="231860282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231860282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231860282">(Mar 25 2021 at 19:17)</a>:</h4>
<p>Particularly that <code>'^1.1</code> gets replaced by <code>'static</code>; let's see if that makes a difference</p>



<a name="231861964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231861964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231861964">(Mar 25 2021 at 19:26)</a>:</h4>
<p>More differences:</p>
<p>rust-analyzer</p>
<div class="codehilite"><pre><span></span><code>unify(Normalize(&lt;{closure:ClosureId(3)}&lt;[                                     for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;?0, (&amp;&#39;?1 ?2)&gt;), ?1 := (&amp;&#39;static 2&lt;?3, ?4&gt;), ?2 := Ordering]&gt;    as FnOnce&lt;2&lt;(&amp;&#39;static 2&lt;?5, ?6&gt;), (&amp;&#39;static 2&lt;?5, ?6&gt;)&gt;&gt;&gt;::Output -&gt; Ordering), Normalize(&lt;{closure:ClosureId(3)}&lt;                                        for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;?7, (&amp;&#39;?8 ?9)&gt;), ?1 := (&amp;&#39;static 2&lt;?10, ?11&gt;), ?2 := Ordering]   &gt; as FnOnce&lt;2&lt;(&amp;&#39;static 2&lt;?7, (&amp;&#39;static ?9)&gt;), (&amp;&#39;static 2&lt;?10, ?11&gt;)&gt;&gt;&gt;::Output -&gt; Ordering)) succeeded
</code></pre></div>
<p>local</p>
<div class="codehilite"><pre><span></span><code>unify(Normalize(&lt;{closure:ClosureId(#4)}&lt;?0, &#39;?1, ?2, ?3, ?4, Int(I8), &quot;rust&quot; for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;?0, (&amp;&#39;?1 ?2)&gt;), ?1 := (&amp;&#39;static 2&lt;?3, ?4&gt;), ?2 := Ordering], 0&gt; as FnOnce&lt;2&lt;(&amp;&#39;static 2&lt;?5, ?6&gt;), (&amp;&#39;static 2&lt;?5, ?6&gt;)&gt;&gt;&gt;::Output -&gt; Ordering), Normalize(&lt;{closure:ClosureId(#4)}&lt;?7, &#39;?8, ?9, ?10, ?11, Int(I8), &quot;rust&quot; for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;?7, (&amp;&#39;?8 ?9)&gt;), ?1 := (&amp;&#39;static 2&lt;?10, ?11&gt;), ?2 := Ordering], 0&gt; as FnOnce&lt;2&lt;(&amp;&#39;static 2&lt;?7, (&amp;&#39;?8 ?9)    &gt;), (&amp;&#39;static 2&lt;?10, ?11&gt;)&gt;&gt;&gt;::Output -&gt; Ordering)) succeeded
</code></pre></div>



<a name="231862178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231862178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231862178">(Mar 25 2021 at 19:27)</a>:</h4>
<p>local, no goals; rust-analyzer: </p>
<div class="codehilite"><pre><span></span><code>goals=[InEnvironment { environment: Env([]), goal: (?0 &lt;: ?7) }, InEnvironment { environment: Env([]), goal: (?2 &lt;: ?9) }, InEnvironment { environment: Env([]), goal: (?3 &lt;: ?10) }, InEnvironment { environment: Env([]), goal: (?4 &lt;: ?11) }, InEnvironment { environment: Env([]), goal: (?7 &lt;: ?0) }, InEnvironment { environment: Env([]), goal: (?9 &lt;: ?2) }, InEnvironment { environment: Env([]), goal: (?10 &lt;: ?3) }, InEnvironment { environment: Env([]), goal: (?11 &lt;: ?4) }]
</code></pre></div>



<a name="231863429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231863429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231863429">(Mar 25 2021 at 19:34)</a>:</h4>
<p>In particular, I'm a bit concerned about <code>InEnvironment { environment: Env([]), goal: (?0 &lt;: ?7) }</code> and <code>InEnvironment { environment: Env([]), goal: (?7 &lt;: ?0) }</code>, though I don't know if that's necessarily the problem here</p>



<a name="231863714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231863714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> detrumi <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231863714">(Mar 25 2021 at 19:36)</a>:</h4>
<p>why the subtype goals all of a sudden? something to do with FnMut?</p>



<a name="231864054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231864054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231864054">(Mar 25 2021 at 19:39)</a>:</h4>
<p>It's because of </p>
<div class="codehilite"><pre><span></span><code>relate_ty_ty variance=Invariant, a=() for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;[?0 := ?0, ?1 := (&amp;&#39;?1 ?2)]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ?3, ?1 := ?4]&gt;), ?2 := Ordering&lt;[]&gt;], b=() for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;[?0 := ?7, ?1 := (&amp;&#39;?8 ?9)]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ?10, ?1 := ?11]&gt;), ?2 := Ordering&lt;[]&gt;]
</code></pre></div>



<a name="231864571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231864571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231864571">(Mar 25 2021 at 19:43)</a>:</h4>
<p>But why the heck is the rust-analyzer solve generating goals but not locally</p>



<a name="231865453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231865453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231865453">(Mar 25 2021 at 19:48)</a>:</h4>
<p>ohh</p>



<a name="231865508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231865508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231865508">(Mar 25 2021 at 19:49)</a>:</h4>
<div class="codehilite"><pre><span></span><code>                0ms DEBUG zip_tys Invariant, ?0, ?7
                relate_ty_ty{variance=Invariant, a=?0, b=?7}
                  unify_var_var{a=?0, b=?7}
                relate_lifetime_lifetime{variance=Invariant, a=&#39;?1, b=&#39;?8}
                  0ms DEBUG var_a=?1, var_b=?8
                0ms DEBUG zip_tys Invariant, ?2, ?9
                relate_ty_ty{variance=Invariant, a=?2, b=?9}
                  unify_var_var{a=?2, b=?9}
                1ms DEBUG zip_tys Invariant, ?3, ?10
                relate_ty_ty{variance=Invariant, a=?3, b=?10}
                  unify_var_var{a=?3, b=?10}
                1ms DEBUG zip_tys Invariant, ?4, ?11
                relate_ty_ty{variance=Invariant, a=?4, b=?11}
                  unify_var_var{a=?4, b=?11}
</code></pre></div>



<a name="231865557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231865557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231865557">(Mar 25 2021 at 19:49)</a>:</h4>
<p>It's because they are a part of the "function signature" part of the substitution</p>



<a name="231865720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231865720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231865720">(Mar 25 2021 at 19:50)</a>:</h4>
<p>Okay so let's see if it's these goals that bite us</p>



<a name="231865758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231865758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231865758">(Mar 25 2021 at 19:51)</a>:</h4>
<p>Well, why are we normalizing these</p>



<a name="231865888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231865888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231865888">(Mar 25 2021 at 19:52)</a>:</h4>
<p>Right because we have a clause that basically says "the output of this closure normalizes to <code>Ordering</code>"</p>



<a name="231865924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231865924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231865924">(Mar 25 2021 at 19:52)</a>:</h4>
<p>and so we need to unify that clause we the goal</p>



<a name="231865987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231865987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231865987">(Mar 25 2021 at 19:53)</a>:</h4>
<p>I think when we unify closures, we should only unify their "function substitution"</p>



<a name="231865997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231865997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231865997">(Mar 25 2021 at 19:53)</a>:</h4>
<p>But maybe that's not right</p>



<a name="231866033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231866033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231866033">(Mar 25 2021 at 19:53)</a>:</h4>
<p>So, again, let's see if it's these goals that bite us</p>



<a name="231867914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231867914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231867914">(Mar 25 2021 at 20:06)</a>:</h4>
<p>Okay, so still going through that</p>



<a name="231868040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231868040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231868040">(Mar 25 2021 at 20:07)</a>:</h4>
<p>But fix for rust-analyzer: put any vars found in the signature in the closure substitution <em>not</em> in function signature</p>



<a name="231868064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231868064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231868064">(Mar 25 2021 at 20:07)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="129457">@Florian Diebold</span></p>



<a name="231868340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231868340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231868340">(Mar 25 2021 at 20:09)</a>:</h4>
<p>I think I'm going to PR a change to Chalk regardless to change <code>closure_inputs_and_output</code> to return <code>Binders&lt;Binders&lt;FnDefInputsAndOutput&gt;&gt;</code> since this more closely matches action fn defs: one level of "early bound" vars and one level of "late bound" vars</p>



<a name="231868665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231868665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231868665">(Mar 25 2021 at 20:11)</a>:</h4>
<p>But once again we're faced with the problem of generating goals like <code>?0 &lt;: ?7</code> and <code>?7 &lt;: ?0</code>. I'm somewhat convinced we should just also convert that to a unification</p>



<a name="231868699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231868699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231868699">(Mar 25 2021 at 20:12)</a>:</h4>
<p>Basically <em>every</em> issue that's come up related to variance would have been solved by that</p>



<a name="231868797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231868797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231868797">(Mar 25 2021 at 20:12)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232957">Jack Huey</span> <a href="#narrow/stream/144729-wg-traits/topic/Functions.20in.20Chalk/near/231868040">said</a>:</p>
<blockquote>
<p>But fix for rust-analyzer: put any vars found in the signature in the closure substitution <em>not</em> in function signature</p>
</blockquote>
<p>I don't think I understand what you mean by that</p>



<a name="231869110"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231869110" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231869110">(Mar 25 2021 at 20:14)</a>:</h4>
<p>So</p>



<a name="231869146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231869146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231869146">(Mar 25 2021 at 20:15)</a>:</h4>
<p>/me goes to find code</p>



<a name="231869216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231869216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231869216">(Mar 25 2021 at 20:15)</a>:</h4>
<p>Well,</p>



<a name="231869292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231869292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231869292">(Mar 25 2021 at 20:16)</a>:</h4>
<p>Right now, only the fn sig is stored in the closure substitution</p>



<a name="231869529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231869529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231869529">(Mar 25 2021 at 20:17)</a>:</h4>
<p>But there are some vars in that signature (in this case, 3) that <em>aren't</em> returned by <code>closure_fn_substitution</code></p>



<a name="231869835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231869835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231869835">(Mar 25 2021 at 20:20)</a>:</h4>
<p>Well, in the <code>Normalize</code> goal, there's 5 (4 types, 1 lifetime)</p>



<a name="231869908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231869908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231869908">(Mar 25 2021 at 20:20)</a>:</h4>
<p>So if you imagine the closure as having a signature of <code>closure foo&lt;T, 'y, U, V, W&gt;(&amp;self, a: &amp;'static (T, &amp;'y U), b: &amp;'static (V, W)) -&gt; Ordering {}</code></p>



<a name="231870082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231870082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231870082">(Mar 25 2021 at 20:21)</a>:</h4>
<p>And then you imagine your goal being:</p>
<div class="codehilite"><pre><span></span><code>exists&lt;T, &#39;y, U, V, W, A, B&gt; {
  Normalize(&lt;foo&lt;T, &#39;y, U, V, W&gt; as FnOnce&lt;(&amp;&#39;static (A, B), &amp;&#39;static (A, B))&gt;&gt;::Output -&gt; Ordering)
}
</code></pre></div>



<a name="231870301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231870301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231870301">(Mar 25 2021 at 20:23)</a>:</h4>
<p>But that <code>foo&lt;T, 'y, U, V, W&gt;</code> is actually represented as </p>
<div class="codehilite"><pre><span></span><code>Closure(foo, [T, &#39;y, U, V, W, for&lt;&gt; fn(&amp;&#39;static (T, &amp;&#39;y U), &amp;&#39;static (V, W)) -&gt; Ordering])
</code></pre></div>



<a name="231870477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231870477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231870477">(Mar 25 2021 at 20:24)</a>:</h4>
<p>Hmm. I was under the impression that that closure substitution would only ever contain lifetimes?</p>



<a name="231870513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231870513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231870513">(Mar 25 2021 at 20:24)</a>:</h4>
<p>Well, so this is where things sort of deviate from rustc, right</p>



<a name="231870552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231870552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231870552">(Mar 25 2021 at 20:25)</a>:</h4>
<p>And why I'm going to PR making <code>closure_inputs_and_output</code> return <code>Binder&lt;Binder&lt;FnDefInputsAndOutput&gt;&gt;</code></p>



<a name="231870737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231870737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231870737">(Mar 25 2021 at 20:26)</a>:</h4>
<p>In rustc, the "function substitution" <em>does</em> contain more than lifetimes</p>



<a name="231870750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231870750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231870750">(Mar 25 2021 at 20:26)</a>:</h4>
<p>See: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.ClosureSubsts.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.ClosureSubsts.html</a></p>



<a name="231870852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231870852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231870852">(Mar 25 2021 at 20:28)</a>:</h4>
<p>(actually, the function substitution part contains <em>all</em> generic parameters in scope, not just those used in the closure)</p>



<a name="231870937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231870937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231870937">(Mar 25 2021 at 20:28)</a>:</h4>
<p>This actually might just be <em>the</em> fix, not <em>a</em> fix</p>



<a name="231870956"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231870956" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231870956">(Mar 25 2021 at 20:28)</a>:</h4>
<p>But <span class="user-mention" data-user-id="116009">@nikomatsakis</span> might want to chime in and give thoughts</p>



<a name="231871025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231871025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231871025">(Mar 25 2021 at 20:29)</a>:</h4>
<p>Hmm. I'm still confused. We never pass lifetime variables to Chalk</p>



<a name="231871154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231871154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231871154">(Mar 25 2021 at 20:30)</a>:</h4>
<p>no, but you pass type variables in the function signature</p>



<a name="231871471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231871471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231871471">(Mar 25 2021 at 20:32)</a>:</h4>
<p>In rustc, I'm pretty sure those might be represented as <code>Param</code>s and so it wouldn't matter</p>



<a name="231872175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231872175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231872175">(Mar 25 2021 at 20:37)</a>:</h4>
<p>but those aren't type parameters of the function, they're type variables coming from some type that needs to be inferred. the number of those could change with every query</p>



<a name="231872413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231872413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231872413">(Mar 25 2021 at 20:38)</a>:</h4>
<p>the closure isn't generic over them either, as opposed to the lifetime variables that the function substitution is for</p>



<a name="231872676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231872676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231872676">(Mar 25 2021 at 20:40)</a>:</h4>
<p>huh?</p>



<a name="231872783"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231872783" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231872783">(Mar 25 2021 at 20:42)</a>:</h4>
<p>Oh, I think I see what you mean</p>



<a name="231873952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231873952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231873952">(Mar 25 2021 at 20:50)</a>:</h4>
<p>Poke <span class="user-mention" data-user-id="116009">@nikomatsakis</span></p>



<a name="231875562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231875562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231875562">(Mar 25 2021 at 21:02)</a>:</h4>
<p>Okay so I've identified the problem and a hacky temp fix that can used</p>



<a name="231875578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231875578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231875578">(Mar 25 2021 at 21:03)</a>:</h4>
<p>But unsure what the "proper" solution is here</p>



<a name="231877329"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231877329" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231877329">(Mar 25 2021 at 21:15)</a>:</h4>
<p>just for completeness: in the original example we have (with shortened names)</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">v</span><span class="p">.</span><span class="n">sort_by</span><span class="p">(</span><span class="o">|</span><span class="p">(</span><span class="n">aa</span><span class="p">,</span><span class="w"> </span><span class="n">sa</span><span class="p">),</span><span class="w"> </span><span class="p">(</span><span class="n">ab</span><span class="p">,</span><span class="w"> </span><span class="n">sb</span><span class="p">)</span><span class="o">|</span><span class="w"> </span><span class="n">sa</span><span class="p">.</span><span class="n">cmp</span><span class="p">(</span><span class="o">&amp;</span><span class="n">sb</span><span class="p">));</span><span class="w"></span>
</code></pre></div>
<p>and RA knows nothing about the elements of <code>v</code>. So during inference of the function, type variables get introduced for <code>aa</code>, <code>sa</code>, <code>ab</code>, <code>sb</code> (let's say <code>?1</code>, <code>?2</code>, <code>?3</code>, <code>?4</code>). The closure would then be represented as <code>closure&lt;fn&lt;&gt;(&amp;(?1, ?2), &amp;(?3, ?4)) -&gt; Ordering&gt;</code>, and when that gets canonicalized you get the bound vars. I think interestingly <code>closure_inputs_and_output</code> gets called with just the substitution for the closure, which contains bound vars referring to binders further out</p>



<a name="231877948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231877948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231877948">(Mar 25 2021 at 21:20)</a>:</h4>
<p>the reason that we get this circular <code>(&amp;(?1, &amp;?2), &amp;(?3, ?2))</code> parameter signature is that when resolving <code>sa.cmp(&amp;sb)</code>, we haven't resolved the types of <code>sa</code> and <code>sb</code> yet, so we don't do the autoref that would actually happen there, and assume that <code>typeof sa == typeof &amp;sb</code></p>



<a name="231877969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231877969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231877969">(Mar 25 2021 at 21:20)</a>:</h4>
<p>(but that's not really relevant to the problem at hand)</p>



<a name="231878504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231878504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231878504">(Mar 25 2021 at 21:24)</a>:</h4>
<p>Yeah the problem here is we have the goal:</p>
<div class="codehilite"><pre><span></span><code>for&lt;type, lifetime, type, type, type&gt; Normalize(&lt;{closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;[?0 := ^1.0, ?1 := (&amp;&#39;^1.1 ^1.2)]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ^1.3, ?1 := ^1.4]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt; as FnOnce&lt;2&lt;[?0 := (&amp;&#39;static 2&lt;[?0 := ^0.5, ?1 := ^0.6]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ^0.5, ?1 := ^0.6]&gt;)]&gt;&gt;&gt;::Output -&gt; Ordering&lt;[]&gt;)
</code></pre></div>
<p>And the clause</p>
<div class="codehilite"><pre><span></span><code>for&lt;type, lifetime, type, type, type&gt; Normalize(&lt;{closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;[?0 := ^1.0, ?1 := (&amp;&#39;^1.1 ^1.2)]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ^1.3, ?1 := ^1.4]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt; as FnOnce&lt;2&lt;[?0 := (&amp;&#39;static 2&lt;[?0 := ^0.0, ?1 := (&amp;&#39;static ^0.2)]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ^0.3, ?1 := ^0.4]&gt;)]&gt;&gt;&gt;::Output -&gt; Ordering&lt;[]&gt;)
</code></pre></div>



<a name="231878587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231878587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231878587">(Mar 25 2021 at 21:25)</a>:</h4>
<p>So we try relate</p>
<div class="codehilite"><pre><span></span><code>Normalize(&lt;{closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;[?0 := ?0, ?1 := (&amp;&#39;?1 ?2)]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ?3, ?1 := ?4]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt; as FnOnce&lt;2&lt;[?0 := (&amp;&#39;static 2&lt;[?0 := ?5, ?1 := ?6]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ?5, ?1 := ?6]&gt;)]&gt;&gt;&gt;::Output -&gt; Ordering&lt;[]&gt;)
</code></pre></div>
<p>and</p>
<div class="codehilite"><pre><span></span><code>Normalize(&lt;{closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;[?0 := ?7, ?1 := (&amp;&#39;?8 ?9)]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ?10, ?1 := ?11]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt; as FnOnce&lt;2&lt;[?0 := (&amp;&#39;static 2&lt;[?0 := ?7, ?1 := (&amp;&#39;static ?9)]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ?10, ?1 := ?11]&gt;)]&gt;&gt;&gt;::Output -&gt; Ordering&lt;[]&gt;)
</code></pre></div>



<a name="231880657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231880657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231880657">(Mar 25 2021 at 21:40)</a>:</h4>
<p>And further:</p>
<div class="codehilite"><pre><span></span><code>{closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;[?0 := ?0, ?1 := (&amp;&#39;?1 ?2)]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ?3, ?1 := ?4]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt;
</code></pre></div>
<p>with</p>
<div class="codehilite"><pre><span></span><code>{closure:ClosureId(3)}&lt;[?0 := () for&lt;0&gt; [?0 := (&amp;&#39;static 2&lt;[?0 := ?7, ?1 := (&amp;&#39;?8 ?9)]&gt;), ?1 := (&amp;&#39;static 2&lt;[?0 := ?10, ?1 := ?11]&gt;), ?2 := Ordering&lt;[]&gt;]]&gt;
</code></pre></div>



<a name="231880883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231880883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231880883">(Mar 25 2021 at 21:42)</a>:</h4>
<p>where does this lifetime variable in the goal and the clause come from though?</p>



<a name="231881220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231881220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231881220">(Mar 25 2021 at 21:45)</a>:</h4>
<p>The <code>AliasEq</code> goal gets generalized</p>



<a name="231881356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231881356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231881356">(Mar 25 2021 at 21:46)</a>:</h4>
<p>tbh I think maybe <code>generalize_lifetime</code> shouldn't try to generalize <code>'static</code></p>



<a name="231881428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231881428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231881428">(Mar 25 2021 at 21:46)</a>:</h4>
<p>But it shouldn't matter</p>



<a name="231882166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/231882166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#231882166">(Mar 25 2021 at 21:52)</a>:</h4>
<p>hm yeah I guess so</p>



<a name="239088385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/239088385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#239088385">(May 17 2021 at 13:28)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> if it helps, this is the thread that I was digging into <a href="https://github.com/rust-lang/chalk/issues/688">chalk#688</a></p>



<a name="239088531"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/239088531" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#239088531">(May 17 2021 at 13:29)</a>:</h4>
<p>oh, I just made a fresh one</p>



<a name="239088555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/239088555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#239088555">(May 17 2021 at 13:29)</a>:</h4>
<p>let's use that one because it has the bug # in the topic name</p>



<a name="239088572"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Functions%20in%20Chalk/near/239088572" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Functions.20in.20Chalk.html#239088572">(May 17 2021 at 13:29)</a>:</h4>
<p>Yes</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>